$(function(){
//    var witch = 0;
    $('.toolbar li').click(function(){
        var _clsArr=$(this).attr('class').split(' ')
        var _oldLink =  window.location.href;
        var _newLink;
        for(var i=_clsArr.length-1;i>=0;i--){
            var _cls = _clsArr[i];
            switch(_cls){ 
                case 'account':
                    _newLink = 'index' ;
                    break;
                case 'transact':
                    _newLink ='transact';
                    break;
                case 'info':
                    _newLink ='info';
                    break;
                case 'setting':
                    _newLink ='setting';
                    break;
            } 
        }
        if(/_self\.html/.test(_oldLink)){
            _newLink += '_self';
        }
        _newLink += '.html';
        var _reg = new RegExp(_newLink);
        if(!_reg.test(_oldLink)){
            window.location.href = _newLink
        }
    })
    $.fn.elemInit=function(elem,margin,count,rect){
        var _w=$(this).width();
        if(typeof(count) == 'number'){
            var _wElm=(_w-(count-1)*margin)/count;
        }else{
            var _wElm = count        
        }
        if(rect){
            $(this).find(elem).css({'height':_wElm+'px','width':_wElm+'px','margin-right':margin+'px','margin-bottom':margin+'px'})    
        }else{
            $(this).find(elem).css({'width':_wElm+'px','margin-right':margin+'px','margin-bottom':margin+'px'})
        }
        $(this).find(elem+':nth-child('+count+'n)').css('margin-right','0')     
    }
    
    window.goHome = function(){
        if(!/_self\.html/.test(window.location.href)){
            window.location.href='index.html';
        }else{ 
            window.location.href = 'index_self.html'
        } 
        
    }
    window.goHistory = function(){
        window.history.back()
    }
})